<#-- 导入模版定义文件-->
<#include "../template/template_editPage.ftl">
<@edit title="易百米产品管理">
	<#if (proInfo)??>
        <#assign isEdit = true />
    <#else>
        <#assign isAdd = true />
    </#if>

<body class="input">
<script type="text/javascript">
		$().ready(function () {
        var $validateErrorContainer = $("#validateErrorContainer");
        var $validateErrorLabelContainer = $("#validateErrorContainer ul");
        var $validateForm = $("#inputForm");
        var $tab = $("#tab");

        // Tab效果
        $tab.tabs(".tabContent", {
            tabs:"input"
        });
		// 表单验证
        $validateForm.validate({
            errorContainer:$validateErrorContainer,
            errorLabelContainer:$validateErrorLabelContainer,
            wrapper:"li",
            errorClass:"validateError",
            ignoreTitle:true,
            rules:{
                "proInfo.oid_goodsitem":{
                    required:true
                },
                "proInfo.name_goods":{
                    required:true
                },
                "proInfo.price":{
                    required:true
                },
                "proInfo.sup_price":{
                    required:true
                }
            },
			messages:{
                "proInfo.oid_goodsitem":{
                    required:"产品编号不能为空！"
                },
                "proInfo.name_goods":{
                    required:"产品名称不能为空！"
                },
                "proInfo.price":{
                    required:"产品面值不能为空！"
                },
                "proInfo.sup_price":{
                    required:"产品进价不能为空！"
                }
            },
            submitHandler:function (form) {
                //$(form).find(":submit").attr("disabled", true);
                form.submit();
            }
        });
        <#if actionErrors?? && (actionErrors?size > 0)>
            $.dialog({type:"warn", content:"<#list errorMessages as list>${list}<br></#list>",
                modal:true, autoCloseTime:3000});
        </#if>

	        $("#submitId").click(function () {
	            var validatorPrice = check2();
	            return  validatorPrice;
	        });
	   	 });
	
		function check1() {
	        $("#priceSpan").html("");
	//        var e = /^(([1-9][0-9]?(.[0-9]{1,3})?)|(0.[0-9]{1,3}))$/;
	        var ee = /^(([1-9]\d*)|\d)(\.\d{1,3})?$/;
	        var blsx = $("#price").val();
	        if (!ee.test(blsx)) {
	            $("#priceSpan").html('价格格式不正确！(例：0.000)');
	            return false;
	        }
	        else {
	            return true;
	        }
	    }
		 function check2() {
        $("#priceSpan2").html('');
//        var e = /^(([1-9][0-9]?(.[0-9]{1,3})?)|(0.[0-9]{1,3}))$/;
        var ee = /^(([1-9]\d*)|\d)(\.\d{1,3})?$/;
        var blsx = $("#sup_price").val();
        if (!ee.test(blsx)) {
            $("#priceSpan2").html('价格格式不正确！(例：0.000)');
            return false;
        }
        else {
            return true;
        }
    }
</script>
	
	<div class="body">
		<div class="inputBar">
       		 <h1><span class="icon">&nbsp;</span><#if isAdd??>添加易百米产品信息<#else>编辑易百米产品信息</#if></h1>
   		</div>
		<div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
	        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
	        <ul></ul>
    	</div>
    	<form id="inputForm" class="validate"
	          action="<#if isAdd??>${web_base}/game/ebai_mi!saveGoodsInfo.htm
	          		  <#else>${web_base}/game/ebai_mi!editGoodsInfo.htm</#if>"
	          method="post">
    	      <input type="hidden" name="proId" value="${proId!}" />
	          <input type="hidden" name="name_goods" value="${name_goods!}" />
	          <input type="hidden" name="productState" value="${productState!}" />
	          <table class="inputTable tabContent">
	          	<#if isAdd??>
	          		<tr>
	                    <th>
	                   		     产品编码:
	                    </th>
	                    <td>
	                        <input type="text" name="proInfo.oid_goodsitem" class="formText {required: true}" value=""/>
	                        <label class="requireField">*</label>
	                    </td>
                    </tr>
	          		<tr>
	                    <th>
	                		        产品名称:
	                    </th>
	                    <td>
	                        <input type="text" name="proInfo.name_goods" class="formText {required: true}" value=""/>
	                        <label class="requireField">*</label>
	                    </td>
             	    </tr>
	          		<tr>
	                    <th>
	                      		  产品面值:(元)
	                    </th>
	                    <td>
	                        <input type="text" id="price" name="proInfo.price"
	                               class="formText {required: true}" value="" onblur="check1()"/>
	                        <span id="priceSpan" style="color: red;"></span>
	                        <label class="requireField">*</label>
	                    </td>
                     </tr>
	          		<tr>
	                    <th>
	                    		    产品进价:(元)
	                    </th>
	                    <td>
	                        <input type="text" id="sup_price" name="proInfo.sup_price"
	                               class="formText {required: true}" value="" onblur="check2()"/>
	                        <span id="priceSpan2" style="color: red;"></span>
	                        <label class="requireField">*</label>
	                    </td>
               		 </tr>
               		 <tr>
	                    <th>
	                    		   备注
	                    </th>
	                    <td>
                            <textarea rows="10" cols="30" id="remark" name="proInfo.remark"
	                               class="formText {required: true}">
	                                
	                        </textarea>
	                    </td>
               		 </tr>
	          	<#else>
	          	   <#if proInfo??>
	          	 		    <input type="hidden" name="proInfo.id" value="${proInfo.id!}"/>
		                    <input type="hidden" name="proInfo.oid_goodsitem" value="${proInfo.oid_goodsitem!}"/>
		                    <input type="hidden" name="proInfo.name_goods" value="${proInfo.name_goods!}"/>
		                    <input type="hidden" name="proInfo.price" value="${proInfo.price!}"/>
		                <tr>
		                    <th>
		                      	  产品编码:
		                    </th>
		                    <td>
		                        ${proInfo.oid_goodsitem!}
		                    </td>
		                </tr>
		                <tr>
		                    <th>
		                       	 产品名称:
		                    </th>
		                    <td>
		                        ${proInfo.name_goods!}
		                    </td>
		                </tr>
		                <tr>
		                    <th>
		                     	   产品进价:(元)
		                    </th>
		                    <td>
		                        <input type="text" id="sup_price" name="proInfo.sup_price"
		                               class="formText {required: true}" value="${proInfo.sup_price!}"
		                               onblur="check2()"/>
		                        <span id="priceSpan2" style="color: red;"></span>
		                    </td>
		                </tr>
		                <tr>
		                    <th>
		                    		   备注
		                    </th>
		                    <td>
		                        <textarea rows="10" cols="30" id="remark" name="proInfo.remark"
		                               class="formText {required: true}">
		                                ${proInfo.remark!}
		                        </textarea>
		                    </td>
               		 </tr>
	          	   </#if>
	          </#if>
	          </table>
	          
	          <div class="buttonArea">
	            <input type="submit" id="submitId" class="formButton" <#if isAdd??> value="添  加" <#else>
	                   value="更  新"</#if> hidefocus="true"/>&nbsp;&nbsp;&nbsp;&nbsp;
	            <input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回"
	                   hidefocus="true"/>
       		 </div>
    	</form>
	</div>
</body>
</@edit>